package com.chuanke.ckfamily.service.finance;
import com.chuanke.ckfamily.dao.finance.model.RedPacket;
import com.chuanke.ckfamily.dao.finance.model.RedPacketRule;
import com.chuanke.ckfamily.service.common.exception.LockException;
import com.chuanke.ckfamily.service.exception.CFException;
import com.chuanke.ckfamily.service.finance.vo.RedPacketInfo;
import com.chuanke.ckfamily.service.finance.vo.RedPacketRecod;
import com.weijie.core.IBaseBiz;

import freemarker.template.TemplateException;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

public interface RedPacketService extends IBaseBiz<RedPacket> {

    /**
     * 检查红包
     *
     */
    void autoCheckRedpacket();

    /**
     * 创建家族红包
     *
     * @param uid
     * @return
     * @throws CFException 
     */
    RedPacketRule createFamilyPackate(Long uid) throws CFException, IOException, TemplateException;

    /**
     * 发家族红包
     *
     * @param uid
     * @param ruleId
     * @throws CFException
     */
    void sendFamilyPacket(Long uid, Long ruleId, String note) throws CFException;

    /**
     * 获取余额
     *
     * @param uid
     * @return
     * @throws CFException
     */
    String getHeaderBalance(Long uid) throws CFException;

    /**
     * 创建个人红包
     *
     * @param uid
     * @return
     * @throws CFException 
     */
    RedPacket createUserPackate(Long uid) throws CFException;

    /**
     * 发个人红包
     *
     * @param uid
     * @param money
     * @param num
     * @throws CFException
     * @throws LockException 
     */
    void sendUserPacket(Long uid, Long money, int num, String note) throws CFException, UnsupportedEncodingException, LockException;

    /**
     * 查找记录
     *
     * @param uid
     * @param p
     * @return
     */
    List<RedPacketRecod> findHistory(Long uid, Integer type, Integer p) throws CFException;

    /**
     *
     *
     * @param uid
     * @return
     */
    Long countHistory(Long uid, Integer type) throws CFException;

    /**
     *
     * @param uid
     * @return
     */
    String sumHistory(Long uid, Integer type) throws CFException;

    RedPacket findByIdUpdate(Long id);

	void sendMemberPacket(Long uid, String tid) throws CFException;

    /**
     * 修正红包
     */
	void updateFalsePacket();

	void updateFalsePacket2();

	void updateFalsePacket3(String pid);

}